# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=mailmunge
pkgver=3.09
pkgrel=0
pkgdesc="email filtering framework that uses libmilter to interface with Postfix or Sendmail"
url="https://mailmunge.org"
arch="all"
license="GPL-2.0-only"
pkgusers="mailmunge"
pkggroups="mailmunge"
depends="
	perl-io-socket-ssl
	perl-html-parser
	perl-mail-dkim
	perl-mime-tools
	perl-socket
	perl-time-local
	perl-unix-syslog
	tzdata
	"
makedepends="libmilter-dev"
checkdepends="
	perl-dbi
	perl-file-find-rule
	perl-html-parser
	perl-json-any
	perl-json-xs
	perl-mail-spamassassin
	perl-net-dns
	perl-dbd-sqlite
	perl-test-deep
	perl-utils
	"
subpackages="$pkgname-openrc $pkgname-doc"
install="$pkgname.pre-install"
source="$pkgname-$pkgver.tar.gz::https://git.skoll.ca/Skollsoft-Public/mailmunge/archive/v$pkgver.tar.gz"
builddir="$srcdir/$pkgname"

prepare() {
	default_prepare
	# delete failing mx DNS test (expects some local addresses)
	rm -f perl/t/91-getmx.t
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--with-perlinstalldirs=vendor \
	make
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install
	# delete systemd and tests
	rm -rf "$pkgdir"/etc/systemd
	rm -rf "$pkgdir"/usr/share/perl*/vendor_perl/Test

	install -dm 750 -o mailmunge -g mailmunge \
		var/spool/mailmunge
}

sha512sums="
841d98912c98d2621138fd009a42bb9124681e10a8490d5d928017834f282183c92d21efa887ea9679ace2647d167f1709c300fd29f98d0502307547c2b55d5f  mailmunge-3.09.tar.gz
"
